'use strict'
const path = require('path')

function resolve(dir) {
  return path.join(__dirname, dir)
}

// const url = 'https://www.fastmock.site/mock/954b6f99d8535977a5debdef75beb2dd/vue_vuetify'

// const port = process.env.port || process.env.npm_config_port || 8372 // dev port
module.exports = {
  transpileDependencies: ['vuetify'],
  publicPath: './',
  lintOnSave: process.env.NODE_ENV === 'development',
  outputDir: 'dist',
  assetsDir: 'static',
  productionSourceMap: false,
  /*   devServer: {
    hot: true,
    port: port,
    open: true,
    overlay: {
      warnings: false,
      errors: true
    },
    proxy: {
      [process.env.VUE_APP_BASE_API]: {
        target: url,
        changeOrigin: true,
        ws: true,
        pathRewrite: {
          ['^' + process.env.VUE_APP_BASE_API]: ''
        }
      }
    }
  }, */
  configureWebpack: {
    name: 'vue-vuetify-admin',
    resolve: {
      alias: {
        '@': resolve('src'),
        api: resolve('src/api'),
        assets: resolve('src/assets'),
        components: resolve('src/components'),
        store: resolve('src/store'),
        styles: resolve('src/styles'),
        utils: resolve('src/utils'),
        variables: resolve('src/variables'),
        views: resolve('src/views')
      }
    }
  },
  chainWebpack(config) {
    // set svg-sprite-loader
    config.module
      .rule('svg')
      .exclude.add(resolve('src/icons'))
      .end()
    config.module
      .rule('icons')
      .test(/\.svg$/)
      .include.add(resolve('src/icons'))
      .end()
      .use('svg-sprite-loader')
      .loader('svg-sprite-loader')
      .options({
        symbolId: 'icon-[name]'
      })
      .end()
  }
}
